<?PHP 
session_start();
include("../config/connect.php");
date_default_timezone_set("Asia/Chongqing");
require_once("../public/common.php");
require_once("../admin/taobaosdk/TopSdk.php");
require_once("../public/biaoqing.php");

$id = CheckUrlParamNoDie("id");

if ($id=="")
	header("location:../tag");

$url = "";
$pic_url="";
$title="";
$price="";
$commission="";

// 因为这个网页调用很少，帮不要作优化了，避免复杂
//$sql = "select * from tk_cache where num_iid='$id' limit 1";
//$result = mysql_query( $sql );
//if ($result && mysql_num_rows($result) > 0)
//{
//	$row = mysql_fetch_assoc( $result );
//	$url = $row["url"];
//	$pic_url=$row["pic_url"];
//	$title=$row["title"];
//	$commission=$row["commission"];
//	$price=$row["fee"];
//}
//else
{
	$json = json_decode(GetItemInfo($id));
	if ($json->code == 1)
	{
		$url = $json->detail_url;
		$pic_url=$json->pic_url;
		$title=$json->title;
		$price=$json->price;

		if (isset($json->click_url))
		{
			$url=$json->click_url;
			$commission=$json->commission;
			$commission_rate=$json->commission_rate;
		}
	}
	else
	{
		header("location:../tag");
	}	
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>兔丝街 - <?PHP echo $title; ?></title>
<link type="text/css" rel="stylesheet" href="../css/base.css" />
<link type="text/css" rel="stylesheet" href="../css/shopping_street=20110716.css" />
<script language="javascript" src="../js/common.js"></script>
</head>
<body class="BabyStreet">
<div id="wrapper">
	<!---head kaishi--->
     <?php
	 //echo date("Y-m-j G:i:s");
		 include("../headtop.php"); 
	?>
    <!-----head 结束----->
	<div id="h_banner" style="margin:5px 0 10px 0;"><a href="#" title="你是爱漂漂的懒女孩儿？你是钟意打扮的美丽达人？2011，流金仲夏，和16万兔丝er一起携手发现美丽吧~"><img src="../images/banner.jpg" /></a></div>
    <!----推荐商品 一 二 三级分类导航---->
    <?php
		//$catelog= urldecode(CheckUrlParamNoDie("cl"));
		//$cl_catelog = $catelog;
		//include("../goods.php"); 
	?>
    <!----推荐商品 导航结束---->
    <div id="main">
    	<div class="grid_12">
        	<!--产品详情-->
        	<div class="grid_9 alpha">
				<div class="singleGoods mt10" style="border-right:1px solid #dedede; background:#fff; display: block;">
					<div class="code_pic">
						<a target="_blank" href="<?PHP echo $url; ?>"><img src="<?PHP echo $pic_url."_250x250.jpg"; ?>" title="<?PHP echo $title; ?>"></a>
					</div>
					<div class="goodsdetail">
						<div class="gs_h">
							<h4 class="f16"><a class="goods_title" target="_blank" href="<?PHP echo $url; ?>"><?PHP echo $title; ?></a></h4>
							<p class="price qz-price">售价<em><?PHP echo $price; ?></em><span <?php if(round(0.6*$commission, 2) == "") echo 'style="display:none"'; ?> ><span class="coin">兔子省</span><span class="fan"><?PHP echo round(0.6*$commission, 2); ?></span>元</span></p>
                            <p class="looklink"><a href="<?PHP echo $url; ?>" target="_blank">查看购买链接</a><span>来源：淘宝网</span></p>
                            <p <?php if ($type == "kk") echo "style='display:none;'"; ?> class="p12"><a class="notlikeit cursor" onclick="onfavorite(<?PHP echo $id; ?>)"><b class="f14 red nums"><span id="favorite" ><?PHP echo rand(0, 100); ?></span></b>喜欢</a></p>
                            <p class="price Recommend" <?php echo 'style="display:none"'; ?>>推荐说：<span style="color:#666; font-size:12px;"></span></p>
                            
                            <div style="margin-left:195px;">
                            	<!-- JiaThis Button BEGIN -->
                                <div id="ckepop">
                                    <span class="jiathis_txt">分享到：</span>
                                    <a class="jiathis_button_qzone"></a>
                                    <a class="jiathis_button_tsina"></a>
                                    <a class="jiathis_button_renren"></a>
                                    <a class="jiathis_button_kaixin001"></a>
                                    <a href="http://www.jiathis.com/share?uid=904300" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
                                    <!--a class="jiathis_counter_style"></a-->
                                </div>
                                <script type="text/javascript">
								var jiathis_config = {
									boldNum:6,
									siteNum:15,
									sm:"tsohu,baidu,t163,taobao,tieba,douban,xiaoyou,hi,51,sina,tianya,mop,thexun",
									url:"http://www.tusijie.com/item/share_page.php?id=<?PHP echo $row["id"]; ?>",
									title:"<?PHP echo $title; ?>",
									pic:"<?PHP echo $pic_url."_310x310.jpg"; ?>",
									data_track_clickback:true,
								}

                                </script>
                                <script type="text/javascript" src="http://v2.jiathis.com/code/jia.js?uid=904300" charset="utf-8"></script>
                                <!-- JiaThis Button END -->
                          
                            </div>
						</div>
					</div>
                    <div class="clear"></div>
                    <div class="clear"></div>
                </div><!-- goods -->
            </div>
            <!----猜你喜欢的其他宝贝--->
            <div class="grid_3 omega">
            	<h2 style="font-size: 14px; height: 34px; line-height: 32px; font-weight: bold;">兔达人的其它分享</h2>
				<ul class="guess">
                <?PHP
				function _RendItem($row)
				{
					$tmpTag = explode(" ", trim($row["tag"]));
					$tmpTag = $tmpTag[0];
					echo "<li><a target='_blank' href='../item/?id=".$row["id"]."'><img src='".$row["pic_url"]."_90x90.jpg"."' title='' alt=''></a><span><a target='_blank' href='../tag?tag=".urlencode($tmpTag)."'>$tmpTag</a></span></li>";
				}
					$sql = "select * from goods_items where datediff(now(), time)<30 order by rand(now()) limit 4";

				$k = 0;
				$res2 = mysql_query( $sql );
				while( $res2 && $row = mysql_fetch_assoc( $res2 ))
				{
					++$k;
					_RendItem($row);
				}
				?>
				</ul>
				<div class="clear"></div>
			</div>
            <!-----标题 最新 最热 列表 海报<a class='il_itemhref' href='?page=".($nPage-1)."$il_param'>------->
            <div style="border-top:1px solid #dedede; padding-bottom:10px; width:100%; overflow:hidden; clear:both;"></div>
            <div class="goodsTitle mt14">
                <ul class="">
                    <li class='active' >喜欢这件宝贝的兔丝们还喜欢</li>
                </ul>
            </div> 
            <!-----推荐内容------->
            <div>
                 <?PHP
				  $il_col = 4;
				  $il_param="&id=$id";

				  include("../itemlist.php"); 
				  ?>
            </div>
        </div>
    </div>
</div>

<!---网尾 kaishi--->
 <?php
     include("../networkend.php"); 
?>
<!-----网尾 结束----->
</body>
</html>

<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F22b7662ec7d02c816ddfd8f6df6e5cea' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-20984072-3']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>

<?PHP 
function GetItemInfo($itemid)
{
	$bOK = 0;
	$c = new TopClient;
	$c->appkey = "12322390";
	$c->secretKey = "33184e84dfc3760bf4b8d7c80474bf6c";
	$req = new ItemGetRequest;
	$req->setFields("detail_url,title,nick,cid,pic_url,num,price");
	$req->setNumIid($itemid);
	$resp = $c->execute($req);
	
	if ($resp->getName() == "item_get_response" && isset($resp->item))
	{
		$str = "{\"code\":1";
		$str .= ",\"detail_url\":\"".$resp->item[0]->detail_url."\"";
		$str .= ", \"pic_url\":\"".$resp->item[0]->pic_url."\"";
		$str .= ", \"title\":\"".$resp->item[0]->title."\"";
		$str .= ", \"price\":\"".$resp->item[0]->price."\"";
		$bOK = 1;
	}
	
	//
//	$c = new TopClient;
	$req = new TaobaokeItemsConvertRequest;
	$req->setFields("click_url,num_iid,commission,commission_rate,price");
	$req->setNumIids($itemid);
	$req->setPid(12696614);
	$resp2 = $c->execute($req);
	
	if ($resp2->getName() == "taobaoke_items_convert_response" && isset($resp2->taobaoke_items))
	{	
		$str .= ", \"click_url\":\"".$resp2->taobaoke_items[0]->taobaoke_item[0]->click_url."\"";
		$str .= ", \"commission\":\"".$resp2->taobaoke_items[0]->taobaoke_item[0]->commission."\"";
		$str .= ", \"commission_rate\":\"".$resp2->taobaoke_items[0]->taobaoke_item[0]->commission_rate."\"";
	}

	if ($bOK == 1)
	{
		$str .= "}";
		return $str;
	}
			
	return "{\"code\":0}";
}
?>